package mark.tom.gear.base.utils

import android.app.Activity
import android.content.Context
import android.os.Bundle
import com.hundsun.gmubase.utils.PermissionCallBack
import com.hundsun.gmubase.utils.PermissionsHelper
import mark.tom.gear.base.callback.CallBack


/**
 * @Description: Permission 工具
 * @Author: ttmk110@163.com
 * @Package: mark.tom.gear.base.utils
 * @Date: 2021/4/2
 * @Copyright: 版权归 Mark 所有
 * <ModifyLog>
 * @ModifyContent:
 * @Author:
 * @Date:
 * </ModifyLog>
 */
object PermissionsUtil {

    /**
     * Description: 标记权限为拒绝状态
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:38
     */
    fun markAllPermissionsDenied(
        permissions: Array<String>,
        grantResults: IntArray,
        context: Context
    ) {
        PermissionsHelper.markAllPermissionsDenied(
            permissions, grantResults, context
        )
    }

    /**
     * Description: 检查权限
     * Copyright: Copyright (c) 2021
     * Project: Gear
     * Author: ttmk110@163.com
     * Date: 2021/4/2 17:38
     */
    fun checkPermission(
        activity: Activity,
        permissions: Array<String>,
        callBack: CallBack<Any, Unit>?
    ) {
        PermissionsHelper.checkPermission(activity, permissions, object : PermissionCallBack {
            override fun onSucessed(data: Bundle?) {
                callBack?.onSuccess("")
            }

            override fun onFailed(data: Bundle?) {
                callBack?.onFail("")
            }
        }, true)
    }
}